const qiniu =require("qiniu")
//上传凭证
var accessKey = 'KU-wUinCdG0Q2qmAO5AEBMOf4_uOyghEqGc3wFUR';
var secretKey = 'ZQaiYVqkjVbXc33ZE7KVlSaQznyfiQ4KNvGKdynf';
var mac = new qiniu.auth.digest.Mac(accessKey, secretKey);

//生成凭证
var keyToOverwrite = '后台问题.txt';
var options = {
  scope: "cloud-doc1"+ ":" + keyToOverwrite,//空间管理名称和文件名（覆盖）
};
var putPolicy = new qiniu.rs.PutPolicy(options);
var uploadToken=putPolicy.uploadToken(mac);

//配置
var config = new qiniu.conf.Config();
// 空间对应的机房(华东)
config.zone = qiniu.zone.Zone_z0;

//本地文件选择
var localFile = "D:/后台问题.txt";
var formUploader = new qiniu.form_up.FormUploader(config);
var putExtra = new qiniu.form_up.PutExtra();
var key='后台问题.txt';
// 文件上传
formUploader.putFile(uploadToken, key, localFile, putExtra, function(respErr,
  respBody, respInfo) {
  if (respErr) {
    throw respErr;
  }
  if (respInfo.statusCode == 200) {
    console.log(respBody);
  } else {
    console.log(respInfo.statusCode);
    console.log(respBody);
  }
});
